import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

//  vue  切换菜单可能报错
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const routes = [
  {
    path: "/login",
    name: "login",
    component: () => import("../views/Login.vue"),
  },
  {
    path: "/",
    name: "home",
    component: () => import("../views/index.vue"),
    children: [
      {
        path: "happy",
        name: "happy",
        component: () => import("../views/Happy.vue"),
      },
      {
        path: "/health",
        name: "health",
        component: () => import("../views/Health.vue"),
      },
      {
        path: "/lunck",
        name: "lunck",
        component: () => import("../views/Lunck.vue"),
      },
      {
        path: "/money",
        name: "money",
        component: () => import("../views/Money.vue"),
      },
      ,
      {
        path: "/time",
        name: "time",
        component: () => import("../views/Time.vue"),
      },
      {
        path: "/photo",
        name: "photo",
        component: () => import("../views/Photo.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});

export default router;
